/**
* This is about <code>BasicTest</code>.
* {@link www.hyperfiction.fr}
* @author shoe[box]
*/

package {

	import org.shoebox.guacamole.Cameras.BasicCam;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import org.shoebox.apps.frakconsole.core.Frak;
	import org.shoebox.guacamole.view.GuaScene;
	import org.shoebox.utils.display.STAGEINSTANCE;
	import org.shoebox.utils.logger.Logger;
	import flash.display.Sprite;
	import flash.events.Event;
	
	/**
	* BasicTest
	* @author shoebox
	*/
	public class BasicTest extends Sprite{
		
		[Embed(source="/../assets/mole.jpg")]
		protected var _mole : Class;
		
		protected var _oCam				: BasicCam;
		protected var _oScene			: GuaScene;
		
		// -------o constructor
		
			/**
			* Constructor of the BasicTest class
			*
			* @public
			* @return	void
			*/
			public function BasicTest() : void {
				_init( );
				_run( );
			}

		// -------o public
			
			/**
			* addModels function
			* @public
			* @param 
			* @return
			*/
			public function addModels() : void {
			
			}
			
		// -------o protected
			
			/**
			* 
			*
			* @param 
			* @return
			*/
			final protected function _init() : void {
				STAGEINSTANCE = stage;
				stage.scaleMode = StageScaleMode.NO_SCALE;
				stage.align = StageAlign.TOP_LEFT;
				Logger.level = Logger.LOGLEVEL_LOG;
				STAGEINSTANCE.addChild( Frak.getInstance() );
				stage.addEventListener( Event.RESIZE , _onResize , false , 10 , true );
			}
			
			/**
			* 
			*
			* @param 
			* @return
			*/
			final protected function _onResize( e : Event = null ) : void {
				if( _oCam )
					_oCam.setSize( stage.stageWidth , stage.stageHeight );
					
				if( _oScene )
					_oScene.setSize( stage.stageWidth , stage.stageHeight );
			}
			
			/**
			* 
			*
			* @param 
			* @return
			*/
			final protected function _run() : void {
				
				_oCam = new BasicCam( );
				
				_oScene = new GuaScene( stage );
				_oScene.connect( _onInit , Event.INIT , 10 , true );
				
				_oScene.activeCam = _oCam;
				
				
			}
			
			/**
			* 
			*
			* @param 
			* @return
			*/
			final protected function _onInit() : void {
				_oScene.setSize( stage.stageWidth , stage.stageHeight );
				addModels( );
				stage.addEventListener( Event.ENTER_FRAME , _onFrame , false , 10 , true );
			}
			
			/**
			* 
			*
			* @param 
			* @return
			*/
			protected function _onFrame( e : Event ) : void {
				_oScene.update( );
			}
			
		// -------o misc

			public static function trc(...args : *) : void {
				Logger.log(BasicTest, args);
			}
	}
}
